﻿@using MvcContrib.PortableAreas
@using QDT.Core
@using QDT.Core.Deals
@using QDT.Core.Projects
@model QDT.Core.Projects.RepaymentScheme
@{
    Layout = null;
    var project = ViewBag.Project as Project;
    var credit = ViewBag.Credit as Credit;
}
<link href="/Content/Default/CSS/AllInvestList.css" rel="stylesheet" type="text/css" />
<script src="/Content/Default/JS/jquery-1.8.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $("#show-datalist tr:odd").attr('class', 'show-start_color');
        $("#show-datalist tr").hover(function () { $(this).attr('style', 'background:#f5f5f5;'); }, function () { $(this).removeAttr('style', 'background:#f5f5f5;'); });
    });
</script>
<style type="text/css">
     .show-table-title
     {
         font-family: "微软雅黑";
         font-size: 14px;
         margin-top: -1px;
         height: 30px;
         background: #f5f5f5;
         border-bottom: 1px solid #dfdfdf;
         position: relative;
     }
    #show-datalist tr
    {
        font-family: "微软雅黑";
        font-size: 14px;
        border-bottom: 1px dashed #dfdfdf;
    }
    .show-ui-round
    {
        margin-top: 20px;
        font-size: 14px;
        font-family: "微软雅黑";
        width: 725px;
        height: 250px;
        color: #ebf6ff;
        position: relative;
    }
</style>
<div id="show-all-detaile">
   
    <div class="show-ui-round">
        <div class="show-ui-firstdiv">
            <div class="show-item-div">
                <div class="show-backing">
                    还款中</div>
                <div class="show-ui-company">
                   @(string.IsNullOrWhiteSpace(project.Parent.IndustryDetail) ? "" : project.Parent.IndustryDetail)
                </div>
            </div>
            <div class="show-item-div">
                <div>
                    @project.Name
                </div>
            </div>
            <div class="show-item-div">
                <div style="float: left;">
                    融资额度<span class="show-size-mag">@project.BorrowAmount.ToMoney("F",10000.00)<span>万</span></span></div>
                <div class="show-insert-div">
                    预期年化收益率<span class="show-size-mag">@project.Rate<span>%</span></span></div>
                <div class="show-insert-div">
                    项目期限<span class="show-size-mag">@project.RepayTime</span>个月</div>
            </div>
            <div class="show-item-div">
                <div style="float: left;">
                    开始计息日：<span style="margin-left: 8px;">@project.RepayStartTime.Value.ToString("yyyy-MM-dd")</span></div>
            </div>
            @if (credit.Money < credit.BuyMoney)
            {
                <div id="show-yimaizhaiquan">
                    <span style="font-size: 14px; color: white;">已买债权</span>
                </div>
            }
        </div>
        <div class="show-ui-seconddiv">
            <div class="show-item-divs">
                <div class="show-insert-divs">
                    未还</div>
                <div class="show-mg-right">
                    @credit.WaitRepayMoney.ToMoney()</div>
            </div>
            <div class="show-item-divs">
                <div class="show-insert-divs">
                    已还</div>
                <div class="show-mg-right">
                    <span>@Model.Stages.Where(x => x.IsRepay && x.Time.Date >= credit.CreateTime.Date).Sum(x => x.Ammount).ToMoney()</span></div>
            </div>
            <div class="show-item-divs">
                <div class="show-insert-divs">
                    现有债权</div>
                <div class="show-mg-right">
                    @credit.Money.ToMoney()</div>
            </div>
            <div class="show-item-divs">
                <div class="show-insert-divs">
                    每日计息约为</div>
                <div class="show-mg-right">
                    @((credit.Money * (decimal)(project.Rate / 100) / 365).ToMoney())</div>
            </div>
        </div>
    </div>
    <div class="show-round-table">
        <ul class="show-table-title">
            <li>期数</li>
            <li style="margin-left: 75px;">时间</li>
            <li style="margin-left: 83px;">类型</li>
            <li style="margin-left: 70px;">计息天数</li>
            <li style="margin-left: 65px;">未还</li>
            <li style="margin-left: 86px;">已还</li>
        </ul>
        <div id="show-scroll-table">
            <table style="width: 100%; border-collapse: collapse;">
                <tbody id="show-datalist">
                    @{
                        var start = project.RepayStartTime.Value;
                        var current = 0;
                    }
                    @foreach (var m in Model.Stages)
                    {
                        if (m.Time < credit.CreateTime.Date)
                        {
                            start = m.Time.Date;
                            continue;
                        }
                        if (current == 1)
                        {
                            current = 2;
                        }
                        if (current == 0 && !m.IsRepay)
                        {
                            current = 1;
                        }
                        <tr id="@(current == 1 ? "today-color" : m.IsRepay ? "" : "furture-color")">
                            <td>
                                @m.Stage
                            </td>
                            <td>@m.Time.ToString("yyyy-MM-dd")</td>
                            <td>
                                @switch (m.RepayType)
                                {
                                    case 1:
                                        <span>利息</span>
                                        break;
                                    case 2:
                                        <span>本金</span>
                                        break;
                                    case 3:
                                        <span>本金和利息</span>
                                        break;
                                }
                            </td>
                            <td>
                                @((m.Time.Date - start.Date).Days)
                                @{
                            start = m.Time.Date;
                                }
                            </td>
                            <td>
                                @if (m.IsRepay)
                                {
                                    <span>0</span>
                                }
                                else
                                {
                                    <span> @m.Ammount.ToMoney()</span>
                                }
                            </td>
                            <td>
                                @if (m.IsRepay)
                                {
                                    <span> @m.Ammount.ToMoney()</span>
                                }
                                else
                                {
                                    <span>0</span>
                                }
                            </td>
                        </tr>
                  
                    }
                </tbody>
            </table>
        </div>
    </div>
</div>
